<template>
  <div class="min-h-screen bg-gray-50">
    <NavBar />

    <div class="max-w-7xl mx-auto px-4 py-8">
      <div class="bg-white rounded-xl shadow p-6 mb-6">
        <div class="text-xl font-semibold">管理后台</div>
        <div class="text-gray-500 mt-1">只有管理员可访问</div>
      </div>

      <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
        <div class="bg-white rounded-lg shadow p-6">
          <div class="text-gray-500">用户总数</div>
          <div class="mt-2 text-2xl font-semibold">—</div>
        </div>
        <div class="bg-white rounded-lg shadow p-6">
          <div class="text-gray-500">作品总数</div>
          <div class="mt-2 text-2xl font-semibold">—</div>
        </div>
        <div class="bg-white rounded-lg shadow p-6">
          <div class="text-gray-500">待审核作品</div>
          <div class="mt-2 text-2xl font-semibold">—</div>
        </div>
      </div>

      <div class="bg-white rounded-lg shadow p-6 mt-6">
        <div class="text-lg font-semibold mb-4">快速入口</div>
        <div class="flex flex-wrap gap-3">
          <button class="btn" @click="go('/admin/novels')">作品审核</button>
          <button class="btn" @click="go('/admin/categories')">分类管理</button>
          <button class="btn" @click="go('/admin/users')">用户管理</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted } from 'vue'
import { useRouter } from 'vue-router'
import NavBar from '@/components/layout/NavBar.vue'
import { userAPI } from '@/api/novel'

const router = useRouter()

const go = (path) => router.push(path)

onMounted(async () => {
  try {
    const res = await userAPI.isAdmin()
    const ok = res?.data?.is_admin
    if (!ok) router.replace('/')
  } catch {
    router.replace('/')
  }
})
</script>

<style scoped>
.btn { padding: 0.5rem 1rem; border: 1px solid #e5e7eb; border-radius: 0.5rem; }
.btn:hover { background: #f9fafb; }
</style>


